<?php

namespace addons\mindmap;

use app\common\library\Menu;
use think\Addons;

/**
 * 插件
 */
class Mindmap extends Addons
{

    /**
     * 插件安装方法
     * @return bool
     */
    public function install()
    {
        $menu = [
            [
                'name'    => 'mindmap',
                'title'   => '思维导图管理',
                'icon'    => 'fa fa-magic',
                'sublist' => [
                    [
                        'name'    => 'mindmap/data',
                        'title'   => '数据管理',
                        'sublist' => [
                            ["name" => "mindmap/data/index", "title" => "查看"],
                            ["name" => "mindmap/data/add", "title" => "添加"],
                            ["name" => "mindmap/data/edit", "title" => "编辑"],
                            ["name" => "mindmap/data/del", "title" => "删除"],
                            ["name" => "mindmap/data/multi", "title" => "批量更新"],
                        ],
                    ],
                    [
                        'name'    => 'mindmap/theme',
                        'title'   => '主题管理',
                        'sublist' => [
                            ["name" => "mindmap/theme/index", "title" => "查看"],
                            ["name" => "mindmap/theme/add", "title" => "添加"],
                            ["name" => "mindmap/theme/edit", "title" => "编辑"],
                            ["name" => "mindmap/theme/del", "title" => "删除"],
                            ["name" => "mindmap/theme/multi", "title" => "批量更新"],
                        ],
                    ],
                ],
            ],
        ];
        Menu::create($menu);
        return true;
    }

    /**
     * 插件卸载方法
     * @return bool
     */
    public function uninstall()
    {
        Menu::delete("mindmap");
        return true;
    }

    /**
     * 插件启用方法
     * @return bool
     */
    public function enable()
    {
        Menu::enable("mindmap");
        return true;
    }

    /**
     * 插件禁用方法
     * @return bool
     */
    public function disable()
    {
        Menu::disable("mindmap");
        return true;
    }

}
